<?php
/**
 * True Gallery Rebuild Back-End Router
 *
 * @version 1.0
 * @author Alexey N. Brin (userxp@joomlaportal.ru)
 * @filename rebuild.php
 * @package True Gallery
 * @copyright (C) 2008-2009 by joomlatune.ru
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 * 
 * If you fork this to create your own project, 
 * please make a reference to True Gallery someplace in your code 
 * and provide a link to http://www.joomlatune.ru
 *
 **/

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');

class JTrueRebuildRouterAdmin extends JoomlaTuneRouter
{
	function _default() {
		JTrueRebuildRouterAdmin::show();
	}
	
	function start( $catid='' ) {
		
		$catid = $catid ? $catid : getUrlParam( 'catid', $catid );
		$pars = &JTuneConfig::getParameters();
		extract( $pars );
		// $ad_crsc - resizing type
		
		$db = &getDBO ();
		$db->setQuery ( 'SELECT * FROM '.TG_TBLPREFIX.' WHERE catid='.$catid );
		$pics = $db->loadObjectList();
		if( $pics[0] != '' ) {
			foreach ( $pics as $pic ) {
				// creating thumb
				$image = TG_ORIGINALSPATH . $catid . DSX . $pic->imgfilename;
				dgImageCreate( 
					$image, TG_THUMBSPATH . $catid . DSX . $pic->imgfilename, 
					$ad_thumbwidth, $ad_thumbheight, $ad_thumbquality, $ad_crsc
				);
				// creating mediumsize picture
				dgImageCreate( 
					$image, TG_PICTURESPATH . $catid . DSX . $pic->imgfilename, 
					$ad_maxwidth, $ad_maxheight, $ad_mediumquality, $ad_crsc
				);
			}
		}
		
		$this->_();
		//JTuneRouter::_ ( TRUE_INDEX2.'&view=rebuild', JText::_ ( 'TG_THUMB_REBUILD_END' ) );
	} //start
	
	function show( $tmpl='admin.rebuild' ) {
		$ad_imgstyle = JTuneConfig::getValue( 'ad_imgstyle' );
		$clist = JTrueGalleryHTMLHelper::showDropDownCategoryList( 0, 'catid', 'class="inputbox" size="1"' );
		reBuildPathes();
		$imgpath = getGalleryImgPath();
		// including layout file
		include_once JTuneLayout::getFile( $tmpl );
		
	} //show
	
} //JTrueRebuildRouterAdmin

class JTrueRebuildRouterSite extends JoomlaTuneRouter
{
	function _default() {
	} //_default
} //JTrueRebuildRouterSite

?>
